<template>
	<view class="my-userinfo">
		<view class="avatar">
			<image :src="userInfo.avatarUrl" mode=""></image>
			<text>{{ userInfo.nickName }}</text>
		</view>
		<view class="content-box">
			<!-- 第一个面板 -->
			<view class="one">
				<view class="one-item">
					<view class="num">8</view>
					<view class="name">收藏的店铺</view>
				</view>
				<view class="one-item">
					<view class="num">14</view>
					<view class="name">收藏的商品</view>
				</view>
				<view class="one-item">
					<view class="num">18</view>
					<view class="name">关注的商品</view>
				</view>
				<view class="one-item">
					<view class="num">84</view>
					<view class="name">足迹</view>
				</view>
			</view>
			<!-- 第二个面板 -->
			<view class="two">
				<view class="title">我的订单</view>
				<view class="twobox">
			 	<view class="two-item">
						<image src="../../static/my-icons/icon1.png" mode=""></image>
						<text>待付款</text>
					</view>
					<view class="two-item">
						<image src='../../static/my-icons/icon2.png' mode=""></image>
						<text>待收货</text>
					</view>
					<view class="two-item">
						<image src="../../static/my-icons/icon3.png" mode=""></image>
						<text>退款/退货</text>
					</view>
					<view class="two-item">
						<image src="../../static/my-icons/icon4.png" mode=""></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			<!-- 第三个面板 -->
			<view class="three">
				<view class="three-item">
					<text>收货地址</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
				<view class="three-item">
					<text>联系客服</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
				<view class="three-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "my-userinfo",
		computed: {
			...mapState('user', ['userInfo']),
		},
		data() {
			return {

			};
		},
		methods: {
			...mapMutations('user', {
				'mylogout': 'logout1'
			}),
			async logout() {
				const [err, res] = await uni.showModal({
					title: '提示',
					content: '是否确定退出登录'
				})
				// 判断
				if (err) return uni.$showMsg()
				if (res.confirm) {
					// 退出登录
					this.mylogout()
					uni.showToast({
						title: '退出登录成功'
					})
				}
			}

		}
	}
</script>

<style lang="scss">
	.my-userinfo {
		background-color: #f4f4f4;
		height: 100%;

		.avatar {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			background-color: #c00;
			height: 400rpx;

			// padding-top: 200rpx;
			image {
				width: 160rpx;
				height: 160rpx;
				border: 2px solid #fff;
				border-radius: 50%;
			}

			text {
				margin-top: 20rpx;
				color: #fff;
			}
		}

		.content-box {
			// background-color: #f4f4f4;
			padding: 0 20rpx;

			.one {
				margin-top: -20rpx;
				margon-bottom: 20rpx;
				padding: 20rpx;
				background-color: #fff;
				display: flex;
				align-items: center;
				border-radius: 10rpx;

				.one-item {
					text-align: center;
					flex: 1;
					font-size: 14px;
				}
			}

			.two {
				background-color: #fff;
				border-radius: 10rpx;
				margin-top: 20rpx;

				.title {
					line-height: 80rpx;
			  border-bottom: 1px solid #f4f4f4;
					padding-left: 20rpx;
				}

				.twobox {
					padding: 20rpx 0;
					display: flex;

					.two-item {
						font-size: 14px;
						flex: 1;
						display: flex;
						flex-direction: column;
						align-items: center;

						image {
							width: 80rpx;
							height: 80rpx;
							margin-bottom: 10rpx;
						}
					}
				}
			}

			.three {
				background-color: #fff;
				border-radius: 10rpx;
				margin-top: 20rpx;

				.three-item {
					padding: 20rpx;
					display: flex;
					justify-content: space-between;
			 	align-items: center;
				}
			}
		}
	}
</style>
